package com.demo.service.impl;

import com.demo.entity.User;
import com.demo.mapper.UserMapper;
import com.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    /**
     * 添加用户
     * @param user 用户对象
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addUser(User user) throws Exception {
        userMapper.insertUser(user.getId(), user.getName());
//        double i = 10/0;
        System.out.println("正常执行");
    }

    /**
     * 根据用户ID查找用户
     * @param id 用户ID
     * @return 用户对象
     */
    @Override
    public User findUserById(Integer id) {
        return null;
    }

}
